\section{Rules}
\label {api-rules}

An Aspen \dfn{rule} is a callable that takes a filesystem path and a predicate
string, and returns \class{True} or \class{False}. Rules are part of Aspen's
handler infrastructure; see the documentation for \file{handlers.conf} for how
to use them.


\begin{funcdesc}{catch_all}{path, predicate}
Always return \class{True}.
\end{funcdesc}

\begin{funcdesc}{fnmatch}{path, predicate}
Match if \var{path} matches the pattern \var{predicate} per the standard
library's \code{fnmatch.fnmatchcase}.
\end{funcdesc}

\begin{funcdesc}{hashbang}{path, predicate}
Match if the file at \var{path} starts with '\#!'.
\end{funcdesc}

\begin{funcdesc}{isdir}{path, predicate}
Match if \var{path} points to a directory.
\end{funcdesc}

\begin{funcdesc}{isfile}{path, predicate}
Match if \var{path} points to a file.
\end{funcdesc}

\begin{funcdesc}{isexecutable}{path, predicate}
Match if the file at \var{path} is executable.
\end{funcdesc}

\begin{funcdesc}{mimetype}{path, predicate}
Match if the mimetype of the file at \var{path} is \var{predicate}.
\end{funcdesc}

\begin{funcdesc}{rematch}{path, predicate}
Match if \var{path} matches the regular expression \var{predicate}.
\end{funcdesc}
